package cn.yan.luowowo.controller;

import cn.yan.luowowo.domain.Destination;
import cn.yan.luowowo.query.DestinationQuery;
import cn.yan.luowowo.service.DestinationService;
import cn.yan.luowowo.service.DestinationService;
import cn.yan.luowowo.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("destination")
public class DestinationController {


    @Autowired
    private DestinationService destinationService;


    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")DestinationQuery qo){

        //目的地导航栏
        model.addAttribute("toasts",destinationService.gettoasts(qo.getParentId()));

        Page<Destination> page = destinationService.query(qo);

        model.addAttribute("page",page);

        return "destination/list";

    }

    //修改地区简介
    @RequestMapping("updateInfo")
    @ResponseBody
    public Object updateInfo(String id, Destination des ){

        String str=des.getInfo();

        Destination destination = destinationService.updateInfo(id,str);


        return JsonResult.success(destination);



    }



    
}
